#region Summary

// 
// Owner : JackieHan 
// 
// Solution : DailyCollection 
// 
// Project : Jackie.Utility
// 
// File : Tree.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 树节点
// 
// History : 
//			2011-05-24 15:01:49	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace Jackie.Utility.CostomCollection
{
    /// <summary> 
    /// 树节点
    /// </summary>
    public class Tree<T>
    {
        /// <summary>
        /// 默认的构造函数
        /// </summary>
        public Tree()
        {
            ChildTrees = new List<Tree<T>>();
        }

        /// <summary>
        /// 构造一个树(根节点)
        /// </summary>
        /// <param name="value">节点的值</param>
        public Tree(T value)
        {
            Value = value;
            ChildTrees = new List<Tree<T>>();
        }

        /// <summary>
        /// 构建一个子树
        /// </summary>
        /// <param name="value">节点的值</param>
        /// <param name="facther">父节点</param>
        public Tree(T value, Tree<T> facther)
            : this(value)
        {
            Father = facther;
        }

        /// <summary>
        /// 父节点
        /// </summary>
        public Tree<T> Father { get; set; }

        /// <summary>
        /// 节点的值
        /// </summary>
        public T Value { get; set; }

        /// <summary>
        /// 树的子树
        /// </summary>
        public IList<Tree<T>> ChildTrees { get; set; }

        /// <summary>
        /// 添加一个子节点
        /// </summary>
        /// <param name="child"></param>
        public void AddChild(Tree<T> child)
        {
            ChildTrees.Add(child);
            child.Father = this;
        }


        /// <summary>
        /// 输出 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var sb = new StringBuilder();
            return sb.ToString();
        }
    }
}